#!/bin/bash
NUM=100000
PASS=123456
CMD=redis-cli

function addKeyNoPassword() {
for i in `seq $NUM`;do
  ${CMD} -h 127.0.0.1 --no-auth-warning set key${i} value${i}
  echo "key${i} value${i} 写入完成"
done
echo "$NUM个key写入到Redis完成"
}

function addKey() {
for i in `seq $NUM`;do
  ${CMD} -h 127.0.0.1 -a "${PASS}" --no-auth-warning set key${i} value${i}
  echo "key${i} value${i} 写入完成"
done
echo "$NUM个key写入到Redis完成"
}

if [ -z ${PASS} ];then
  addKeyNoPassword
else
  addKey
fi


